package com.bjpowernode.web;

import com.bjpowernode.query.TranQuery;
import com.bjpowernode.result.R;
import com.bjpowernode.service.TTranService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 */
@RestController
@Slf4j
@RequestMapping("/api/tran")
public class TTranController {

    @Resource
    private TTranService tTranService;

    @PostMapping("save")
    public R createTran(TranQuery tranQuery,
                        @RequestHeader(value = "Authorization") String jwt) {
        log.info("要创建的交易数据: {}" , tranQuery);
        tranQuery.setJwt(jwt);
        int save = tTranService.createTran(tranQuery);
        return save >= 1 ? R.OK() : R.FAIL();
    }
}
